#include "../../mqcommon/helper.hpp"



int main()
{
    // 1.对已经有的文件的测试
    FileHelper helper("../../mqcommon/logger.hpp");
    DLOG("文件是否存在: %d", helper.exists());
    DLOG("文件是大小: %ld", helper.size());

    //2.对不存在的文件测试
    FileHelper copy_helper("./aaa/bbb/ccc/copy.hpp");
    if(copy_helper.exists() == false)
    {
        //创建目录
        std::string directory = copy_helper.getParentDirectory();
        if(FileHelper(directory).exists() == false)
        {
            FileHelper::createDirectory(directory);
        }
        //创建文件
        copy_helper.createFile("./aaa/bbb/ccc/copy.hpp");
    }
    std::string buffer;
    //读
    helper.read(buffer);
    // DLOG("%s", buffer.c_str());
    //写
    copy_helper.write(buffer);

    //3.局部读
    std::string buffer_line;
    copy_helper.read(buffer_line, 1, 11);
    // std::cout << buffer_line << std::endl; 
    //4.局部写
    copy_helper.write("000000", 1, 6);
    //5.rename
    copy_helper.rename("./aaa/bbb/ccc/copy.txt");
    //6.删除文件
    FileHelper::removeFile("./aaa/bbb/ccc/copy.txt");
    //7.删除目录
    FileHelper::removeDirectory("./aaa");

    return 0;
}
